home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
101-125
/
scopedisk125
/
usmap
/
readme
< prev
next >
Wrap
Text File
|
1995-03-19
|
5KB
|
104 lines
Here is an example of one way to implement irregularly shaped buttons
in The Director. The example used is a US map, where each state is a
seperate button.
This demo for this example, and the utility that helps to create a
table of buttons for applications like the example, can both be run
using the Projector, The Director's player program which can be found
elsewhere in this library.
The technique used is this. First, the screen image is designed in
a paint program or whatever, where there are areas on the screen that
are to be used as buttons. Then a second version of this screen image
is created, and all of the active button areas replaced with solid
colors. Compare the IFF image files, USMAP1 and USMAP2 to see an
example. USMAP2 has each button area colored in as a solid color.
It is also important to use colors so that a rectangle can be drawn around
any button that will not overlap another button of the same color.
In the example USMAP2, only 6 colors are used to color the states.
It is determined that a given button has been clicked, when two conditions
are met: 1. The click occurs within the buttons boundary rectangle, and
2. The pixel color of the clicked-on pixel in the mask image (USMAP2)
is the proper color.
A table in the array is used to hold all of the button locations and
colors. Every 7 elements constitute a button entry, where the upper
left x,y, lower right x,y, color values and fill location (for highlighting)
are contained. The table ends with a -1 as the upper left x value.
Example:
50 upper left x
50 upper left y
100 lower right x
75 lower right y
7 color 7 for this button
70 fill location x
70 fill location y
-1 end of table
To facilitate easy creation of the button table, a Director utility script,
"gbuttons" was created that will allow you the mask image to be loaded and
the boundary rectangle specified (by clicking once in each corner of the
rectangle, and then hitting return) and then the proper color of the
button selected by clicking on the button itself. "gbuttons" will create
a file, "ram:btable" which contains all of the data for the buttons
specified. This file can then be used as in the example "domap" script
(where ram:btable has been renamed "us.table") read in to the array
and used to define the button areas in the application. Note that
every time "gbuttons" is rerun the file "ram:btable" will be created
as new, deleting any old data that may be in the file from the previous
use of "gbuttons". It is a good idea to rename the "ram:btable" file
once it has been created. Since the file produced is readable ASCII,
it is possible to cut and paste these files to assemble button data
generated independently, but remember that each button consists of 7
values, and there is a -1 only at the end of the table.
The script "domap" loads in the button screen and the button mask,
and starts in a demo mode where the states are highlighted at random.
Once the mouse is clicked on a state, a window will appear with the
text that is contained in a text file associated with the button. These
text files are named STATE01...STATE48 (Alaska & Hawaii weren't
included). When the mouse is clicked, it's location is converted into
a button number from 1-48, or a 0 if no button was hit. (actually, 1-50,
as buttons 49 and 50 are the exit and demo buttons). The button number
is converted into the appropriate state's filename, and the file is
read and displayed in the text window.
Highlighting is accomplished by coping the mask image into a scratch
buffer and FILLing from the fill point in the button table with color 0.
This resultant image is then used to stencil a solid color screen image
into place on the viewed map. This stencil technique requires the use
of up to 4 buffers which may make it impractical for hi-res applications,
though there may be other highlighting techniques that could be
substituted, or highlighting could be dispensed with entirely. If a
hi-res version is desired, you might note that the mask image does not
have to be hi-res, the x,y mouse coordinates could be halved and used
with a low-res mask image, since the mask image is never seen anyway.
To run the examples from the workbench, download a copy of The Director's
"projector" program from this library, and type:
projector domap.film
to run the finished application example, or:
projector gbuttons.film
to run the button utility. Specify USMAP2 as the mask image when
using the US map to try the button utility.
To run these examples from the Workbench, copy the projector and
the projector's icon file "projector.info" into the directory that
contains the files for the demos, and click on the icons from the
Workbench.
Good luck.
Keith Doyle
4/10/90